﻿namespace PagedDataGridView
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Paged List
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PagedList<T> : List<T>, IPagedList<T>
    {
        /// <summary>
        /// Page
        /// </summary>
        public IPageData Page { get; set; }

        /// <summary>
        /// ctor with page only
        /// </summary>
        /// <param name="page">optional Page info</param>
        public PagedList(IPageData page)
        {
            Page = page;
        }

        /// <summary>
        /// ctor with page and collection
        /// </summary>
        /// <param name="page">optional Page info</param>
        /// <param name="collection">collection of items on a page</param>
        public PagedList(IPageData page, IList<T> collection)
            : this(page)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("adding null collection to a paged list is not allowed",
                                                "collection");
            }
            AddRange(collection);
        }
    }
}
